//
// Created by wxd on 2025/7/11.
//

#include "Shader.h"

#include <sstream>
#include <iostream>
#include "../../wrapper/log/Logger.h"
#include "../utils/ShaderUtils.hpp"

#define SHADER_PACKAGE_NAME "glframework/shader/Shader.h"

Shader::Shader(const char *vertexPath, const char *fragmentPath) {
    mProgramId = ShaderUtils::LoadShader(vertexPath, fragmentPath);
}

Shader::Shader(const std::string &vertexPath, const std::string &fragmentPath) {
    mProgramId = ShaderUtils::LoadShader(vertexPath.c_str(), fragmentPath.c_str());
}

Shader::~Shader() {

}

GLuint Shader::getProgramId() const {
    return mProgramId;
}


void Shader::bindProgram() const {
    glUseProgram(mProgramId);
}

void Shader::unbindProgram() const {
    glUseProgram(0);
}

void Shader::deleteProgram() const {
    glDeleteProgram(mProgramId);
}

GLuint Shader::getLocation(GLuint programId, const std::string &name) const {
    return glGetAttribLocation(programId, name.c_str());
}

GLuint Shader::getLocation(const std::string &name) const {
    return glGetAttribLocation(mProgramId, name.c_str());
}












